/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: jse2204 - T5
 * <p>Powered by webrx On 2022-09-30 09:31:48
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T5 {
    public static void main(String[] args) {
        Thread t = Thread.currentThread();
        t.setPriority(10);
        System.out.println(t.getId());
        System.out.println(t.getState());
        System.out.println(t.getName());
        System.out.println(t.getPriority());


        Thread t2 = new Thread(()->{
            //t2 线程输出
            String tn = Thread.currentThread().getName();
            for (int i = 0; i < 10; i++) {
                System.out.printf("%s : %d%n",tn,i);
            }
        },"t2");
        t2.setName("第二线程");
        t2.setPriority(Thread.MIN_PRIORITY);

        t2.start();

        //main 线程输出
        for (int i = 0; i < 10; i++) {
            try{
                TimeUnit.SECONDS.sleep(1);
                //Thread.sleep(1000);
            }catch(Exception e){
                e.printStackTrace();
            }
            System.out.printf("%s : %d%n",t.getName(),i);
        }

    }
}
